diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js')
-rw-r--r-- | tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js new file mode 100644 index 00000000..6cef4a7c --- /dev/null +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js @@ -0,0 +1,36 @@ +( function ( mw ) { + QUnit.module( 'mediawiki.storage' ); + + QUnit.test( 'set/get with localStorage', 3, function ( assert ) { + this.sandbox.stub( mw.storage, 'localStorage', { + setItem: this.sandbox.spy(), + getItem: this.sandbox.stub() + } ); + + mw.storage.set( 'foo', 'test' ); + assert.ok( mw.storage.localStorage.setItem.calledOnce ); + + mw.storage.localStorage.getItem.withArgs( 'foo' ).returns( 'test' ); + mw.storage.localStorage.getItem.returns( null ); + assert.strictEqual( mw.storage.get( 'foo' ), 'test', 'Check value gets stored.' ); + assert.strictEqual( mw.storage.get( 'bar' ), null, 'Unset values are null.' ); + } ); + + QUnit.test( 'set/get without localStorage', 3, function ( assert ) { + this.sandbox.stub( mw.storage, 'localStorage', { + getItem: this.sandbox.stub(), + removeItem: this.sandbox.stub(), + setItem: this.sandbox.stub() + } ); + + mw.storage.localStorage.getItem.throws(); + assert.strictEqual( mw.storage.get( 'foo' ), false ); + + mw.storage.localStorage.setItem.throws(); + assert.strictEqual( mw.storage.set( 'foo', 'test' ), false ); + + mw.storage.localStorage.removeItem.throws(); + assert.strictEqual( mw.storage.remove( 'foo', 'test' ), false ); + } ); + +}( mediaWiki ) ); |