Skip to content

Commit

Permalink
add bind test
Browse files Browse the repository at this point in the history
  • Loading branch information
William Chou committed Jun 27, 2017
1 parent 617b035 commit 5c32da5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
36 changes: 32 additions & 4 deletions extensions/amp-bind/0.1/test/test-bind-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {AmpEvents} from '../../../../src/amp-events';
import {Bind} from '../bind-impl';
import {BindEvents} from '../bind-events';
import {chunkInstanceForTesting} from '../../../../src/chunk';
import {installTimerService} from '../../../../src/service/timer-impl';
import {toArray} from '../../../../src/types';
import {user} from '../../../../src/log';

Expand Down Expand Up @@ -109,8 +108,39 @@ function waitForEvent_(bind, env) {
// Unit tests
////////////////////////////////////////////////////////////////////////////////

describes.realWin('Bind', {
describes.realWin('Bind in shadow ampdoc', {
amp: {
ampdoc: 'shadow',
runtimeOn: false,
}
}, env => {
let bind;

let createElementWithBinding;

beforeEach(() => {
// Make sure we have a chunk instance for testing.
chunkInstanceForTesting(env.ampdoc);

bind = new Bind(env.ampdoc);
parent = env.ampdoc.getBody();

createElementWithBinding = createElementWithBinding_(parent, env);
onBindReady = onBindReady_(bind, env);
});

it('should scan for bindings when ampdoc is ready', () => {
createElementWithBinding('[text]="1+1"');
expect(bind.boundElements_.length).to.equal(0);
return onBindReady().then(() => {
expect(bind.boundElements_.length).to.equal(1);
});
});
});

describes.realWin('Bind in single ampdoc', {
amp: {
ampdoc: 'single',
runtimeOn: false,
},
}, env => {
Expand All @@ -124,8 +154,6 @@ describes.realWin('Bind', {
let waitForEvent;

beforeEach(() => {
installTimerService(env.win);

// Make sure we have a chunk instance for testing.
chunkInstanceForTesting(env.ampdoc);

Expand Down
2 changes: 1 addition & 1 deletion testing/describes.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export let TestSpec;
/**
* An object specifying the configuration of an AmpFixture.
*
* - ampdoc: "single", "shadow", "multi", "none".
* - ampdoc: "single", "shadow", "multi", "none", "fie".
*
* @typedef {{
* runtimeOn: (boolean|undefined),
Expand Down

0 comments on commit 5c32da5

Please sign in to comment.