Skip to content

Commit

Permalink
Merge pull request #16029 from thoov/ember-routing-test-conversion
Browse files Browse the repository at this point in the history
[CLEANUP] Convert ember-routing tests to new style (Part 2)
  • Loading branch information
locks authored Dec 25, 2017
2 parents 92f664b + ea8d93e commit 4ec2098
Show file tree
Hide file tree
Showing 4 changed files with 784 additions and 784 deletions.
66 changes: 35 additions & 31 deletions packages/ember-routing/tests/system/cache_test.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
import BucketCache from '../../system/cache';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

moduleFor('BucketCache', class extends AbstractTestCase {
constructor() {
super();

QUnit.module('BucketCache', {
setup() {
this.cache = BucketCache.create();
}
});

QUnit.test('has - returns false when bucket is not in cache', function(assert) {
assert.strictEqual(this.cache.has('foo'), false);
assert.strictEqual(this.cache.has('constructor'), false);
});
['@test has - returns false when bucket is not in cache'](assert) {
assert.strictEqual(this.cache.has('foo'), false);
assert.strictEqual(this.cache.has('constructor'), false);
}

QUnit.test('has - returns true when bucket is in cache', function(assert) {
let token = {};
['@test has - returns true when bucket is in cache'](assert) {
let token = {};

this.cache.stash('foo', 'bar', token);
this.cache.stash('constructor', 'bar', token);
this.cache.stash('foo', 'bar', token);
this.cache.stash('constructor', 'bar', token);

assert.strictEqual(this.cache.has('foo'), true);
assert.strictEqual(this.cache.has('constructor'), true);
});
assert.strictEqual(this.cache.has('foo'), true);
assert.strictEqual(this.cache.has('constructor'), true);
}

QUnit.test('lookup - returns stashed value if key does exist in bucket', function(assert) {
let token = {};
let defaultValue = {};
['@test lookup - returns stashed value if key does exist in bucket'](assert) {
let token = {};
let defaultValue = {};

this.cache.stash('foo', 'bar', token);
this.cache.stash('foo', 'bar', token);

assert.strictEqual(this.cache.lookup('foo', 'bar', defaultValue), token);
});
assert.strictEqual(this.cache.lookup('foo', 'bar', defaultValue), token);
}

QUnit.test('lookup - returns default value if key does not exist in bucket', function(assert) {
let token = {};
let defaultValue = {};
['@test lookup - returns default value if key does not exist in bucket'](assert) {
let token = {};
let defaultValue = {};

this.cache.stash('foo', 'bar', token);
this.cache.stash('foo', 'bar', token);

assert.strictEqual(this.cache.lookup('foo', 'boo', defaultValue), defaultValue);
assert.strictEqual(this.cache.lookup('foo', 'constructor', defaultValue), defaultValue);
});
assert.strictEqual(this.cache.lookup('foo', 'boo', defaultValue), defaultValue);
assert.strictEqual(this.cache.lookup('foo', 'constructor', defaultValue), defaultValue);
}

QUnit.test('lookup - returns default value if bucket does not exist', function(assert) {
let defaultValue = {};
['@test lookup - returns default value if bucket does not exist'](assert) {
let defaultValue = {};

assert.strictEqual(this.cache.lookup('boo', 'bar', defaultValue), defaultValue);
assert.strictEqual(this.cache.lookup('constructor', 'bar', defaultValue), defaultValue);
assert.strictEqual(this.cache.lookup('boo', 'bar', defaultValue), defaultValue);
assert.strictEqual(this.cache.lookup('constructor', 'bar', defaultValue), defaultValue);
}
});

Loading

0 comments on commit 4ec2098

Please sign in to comment.