-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
427d8e0
commit 60ca7c2
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import AmpState from '../AmpState'; | ||
|
||
describe('AmpState', (): void => { | ||
it('returns a directive with `src` attribute set', (): void => { | ||
const src = 'test'; | ||
const wrapper = mount(<AmpState src={src} />); | ||
expect(wrapper.find(`amp-state[src="${src}"]`).exists()).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Html from '../Html'; | ||
|
||
describe('Html', (): void => { | ||
it("doesn't set the `format` attribute if it isn't given", (): void => { | ||
// Use `shallow` here since `html` tags can't really be mounted | ||
const wrapper = shallow( | ||
<Html | ||
// @ts-ignore | ||
format={null} | ||
> | ||
<body> | ||
<h1>Hello, world!</h1> | ||
</body> | ||
</Html>, | ||
); | ||
['amp', 'amp4ads', 'amp4email'].forEach( | ||
(format): void => { | ||
expect(wrapper.find(`html[format="${format}"]`).length).toBe(0); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Script from '../Script'; | ||
|
||
describe('Script', (): void => { | ||
it('returns `null` if `src` or if both `extension` and `version` are missing', (): void => { | ||
const wrapperSrc = mount(<Script src="" />); | ||
expect(wrapperSrc.find('script').exists()).toBe(false); | ||
|
||
const wrapperExtensionVersion = mount(<Script extension="" version="" />); | ||
expect(wrapperExtensionVersion.find('script').exists()).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import getScriptSource from '../getScriptSource'; | ||
|
||
describe('getScriptSource', (): void => { | ||
it('returns a url', (): void => { | ||
const src = 'test-src'; | ||
const extension = 'test-extension'; | ||
const version = 'test-version'; | ||
|
||
expect(getScriptSource({ src, extension, version })).toBe(src); | ||
expect(getScriptSource({ src })).toBe(src); | ||
expect(getScriptSource({ extension, version })).toBe( | ||
`https://cdn.ampproject.org/v0/${extension}-${version}.js`, | ||
); | ||
expect(getScriptSource({ version })).toBe( | ||
`https://cdn.ampproject.org/v0/-${version}.js`, | ||
); | ||
expect(getScriptSource({ extension })).toBe( | ||
`https://cdn.ampproject.org/v0/${extension}-latest.js`, | ||
); | ||
}); | ||
}); |