mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:01:14 +08:00
ES6: Convert all test files over
This commit is contained in:
71
test/javascripts/lib/preload-store-test.js.es6
Normal file
71
test/javascripts/lib/preload-store-test.js.es6
Normal file
@ -0,0 +1,71 @@
|
||||
module("Discourse.PreloadStore", {
|
||||
setup: function() {
|
||||
PreloadStore.store('bane', 'evil');
|
||||
}
|
||||
});
|
||||
|
||||
test("get", function() {
|
||||
blank(PreloadStore.get('joker'), "returns blank for a missing key");
|
||||
equal(PreloadStore.get('bane'), 'evil', "returns the value for that key");
|
||||
});
|
||||
|
||||
test("remove", function() {
|
||||
PreloadStore.remove('bane');
|
||||
blank(PreloadStore.get('bane'), "removes the value if the key exists");
|
||||
});
|
||||
|
||||
asyncTestDiscourse("getAndRemove returns a promise that resolves to null", function() {
|
||||
expect(1);
|
||||
|
||||
PreloadStore.getAndRemove('joker').then(function(result) {
|
||||
blank(result);
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTestDiscourse("getAndRemove returns a promise that resolves to the result of the finder", function() {
|
||||
expect(1);
|
||||
|
||||
var finder = function() { return 'batdance'; };
|
||||
PreloadStore.getAndRemove('joker', finder).then(function(result) {
|
||||
equal(result, 'batdance');
|
||||
start();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
asyncTestDiscourse("getAndRemove returns a promise that resolves to the result of the finder's promise", function() {
|
||||
expect(1);
|
||||
|
||||
var finder = function() {
|
||||
return Ember.Deferred.promise(function(promise) { promise.resolve('hahahah'); });
|
||||
};
|
||||
|
||||
PreloadStore.getAndRemove('joker', finder).then(function(result) {
|
||||
equal(result, 'hahahah');
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTestDiscourse("returns a promise that rejects with the result of the finder's rejected promise", function() {
|
||||
expect(1);
|
||||
|
||||
var finder = function() {
|
||||
return Ember.Deferred.promise(function(promise) { promise.reject('error'); });
|
||||
};
|
||||
|
||||
PreloadStore.getAndRemove('joker', finder).then(null, function(result) {
|
||||
equal(result, 'error');
|
||||
start();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
asyncTestDiscourse("returns a promise that resolves to 'evil'", function() {
|
||||
expect(1);
|
||||
|
||||
PreloadStore.getAndRemove('bane').then(function(result) {
|
||||
equal(result, 'evil');
|
||||
start();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user