Skip to content

Commit a094a33

Browse files
dozingcatjelbourn
authored andcommitted
feat(icon): initial md-icon implementation (#281)
1 parent f8c8ae6 commit a094a33

17 files changed

+1255
-2
lines changed

src/components/icon/fake-svgs.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import {
2+
Response,
3+
ResponseOptions} from 'angular2/http';
4+
5+
/**
6+
* Fake URLs and associated SVG documents used by tests.
7+
*/
8+
const FAKE_SVGS = (() => {
9+
const svgs = new Map<string, string>();
10+
svgs.set('cat.svg',
11+
'<svg><path id="meow"></path></svg>');
12+
13+
svgs.set('dog.svg',
14+
'<svg><path id="woof"></path></svg>');
15+
16+
svgs.set('farm-set-1.svg', `
17+
<svg>
18+
<defs>
19+
<g id="pig"><path id="oink"></path></g>
20+
<g id="cow"><path id="moo"></path></g>
21+
</defs>
22+
</svg>
23+
`);
24+
25+
svgs.set('farm-set-2.svg', `
26+
<svg>
27+
<defs>
28+
<g id="cow"><path id="moo moo"></path></g>
29+
<g id="sheep"><path id="baa"></path></g>
30+
</defs>
31+
</svg>
32+
`);
33+
34+
svgs.set('arrow-set.svg', `
35+
<svg>
36+
<defs>
37+
<svg id="left-arrow"><path id="left"></path></svg>
38+
<svg id="right-arrow"><path id="right"></path></svg>
39+
</defs>
40+
</svg>
41+
`);
42+
43+
return svgs;
44+
})();
45+
46+
/**
47+
* Returns an HTTP response for a fake SVG URL.
48+
*/
49+
export function getFakeSvgHttpResponse(url: string) {
50+
if (FAKE_SVGS.has(url)) {
51+
return new Response(new ResponseOptions({
52+
status: 200,
53+
body: FAKE_SVGS.get(url),
54+
}));
55+
} else {
56+
return new Response(new ResponseOptions({status: 404}));
57+
}
58+
}

0 commit comments

Comments
 (0)