Skip to content

Commit

Permalink
Add test for hideEmptyModelTypes (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlfurniss authored and RobbieTheWagner committed Sep 1, 2018
1 parent 0adc9ba commit c8d5714
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/acceptance/data-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { triggerPort } from '../helpers/trigger-port';
import wait from 'ember-test-helpers/wait';
import LocalStorageService from 'ember-inspector/services/storage/local';

let port, name;

Expand Down Expand Up @@ -32,6 +33,10 @@ module('Data Tab', function(hooks) {

hooks.afterEach(function() {
name = null;
// This is to ensure the hiding empty models setting does not persist across multiple test runs.
let storageServiceToUse = LocalStorageService.SUPPORTED ? 'local' : 'memory';
let storageService = this.owner.lookup(`service:storage/${storageServiceToUse}`);
storageService.removeItem('are-model-types-hidden');
});

function modelTypeFactory(options) {
Expand Down Expand Up @@ -168,6 +173,29 @@ module('Data Tab', function(hooks) {
assert.dom(lastRowColumns[0]).hasText('2', 'Records successfully removed.');
});

test('Hiding empty model types', async function(assert) {
assert.expect(3);

await visit('/data/model-types');

// Make one model type have a count of 0
await triggerPort(this, 'data:modelTypesUpdated', {
modelTypes: [
modelTypeFactory({ name: 'App.Post', count: 0 })
]
});

assert.dom('.js-model-type').exists({ count: 2 }, 'All models are present');

// Hide empty models
await click('#options-hideEmptyModelTypes');
assert.dom('.js-model-type').exists({ count: 1 }, 'Only non-empty models are present');

// Show empty models
await click('#options-hideEmptyModelTypes');
assert.dom('.js-model-type').exists({ count: 2 }, 'All models are present again');
});

test('Filtering records', async function t(assert) {
await visit('/data/model-types');

Expand Down

0 comments on commit c8d5714

Please sign in to comment.