diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-02-10 09:41:11 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-02-10 12:05:43 +0100 |
commit | c47a0a01534d81f923d2d1f69da764f1c6a3754e (patch) | |
tree | c9ec30a1a74835b9a3d48577d00986326ac7c5c3 /core/src/tests | |
parent | df4ca949f533513a9ea90afa363c0bd0ee74c134 (diff) | |
download | nextcloud-server-c47a0a01534d81f923d2d1f69da764f1c6a3754e.tar.gz nextcloud-server-c47a0a01534d81f923d2d1f69da764f1c6a3754e.zip |
Add more tests for the new js modules
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/src/tests')
-rw-r--r-- | core/src/tests/OC/requesttoken.spec.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/core/src/tests/OC/requesttoken.spec.js b/core/src/tests/OC/requesttoken.spec.js index 401d3766af4..d19a4b8e9c8 100644 --- a/core/src/tests/OC/requesttoken.spec.js +++ b/core/src/tests/OC/requesttoken.spec.js @@ -19,12 +19,37 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +import {JSDOM} from 'jsdom' import {subscribe, unsubscribe} from '@nextcloud/event-bus' -import {setToken} from '../../OC/requesttoken' +import {manageToken, setToken} from '../../OC/requesttoken' describe('request token', () => { + let dom + let emit + let manager + const token = 'abc123' + + beforeEach(() => { + dom = new JSDOM() + emit = sinon.spy() + const head = dom.window.document.getElementsByTagName('head')[0] + head.setAttribute('data-requesttoken', token) + + manager = manageToken(dom.window.document, emit) + }) + + it('reads the token from the document', () => { + expect(manager.getToken()).to.equal('abc123') + }) + + it('remembers the updated token', () => { + manager.setToken('bca321') + + expect(manager.getToken()).to.equal('bca321') + }) + describe('@nextcloud/auth integration', () => { let listener |