|
| 1 | +/** |
| 2 | + * Copyright 2021 The AMP HTML Authors. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS-IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +import {getBuilders} from '#compiler/builders'; |
| 17 | + |
| 18 | +describes.sandboxed('getBuilders', {}, () => { |
| 19 | + it('should return an empty list for empty component list', () => { |
| 20 | + const components = {}; |
| 21 | + expect(getBuilders(components)).to.eql({}); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should return eligible builtins when provided them as components', () => { |
| 25 | + const components = {'amp-layout': 'v0'}; |
| 26 | + const builders = getBuilders(components); |
| 27 | + expect(builders).have.all.keys(['amp-layout']); |
| 28 | + }); |
| 29 | + |
| 30 | + it('eligible component with ineligible version is not used', () => { |
| 31 | + const components = {'amp-fit-text': '1.0'}; |
| 32 | + const builders = getBuilders(components); |
| 33 | + expect(builders).to.eql({}); |
| 34 | + }); |
| 35 | + |
| 36 | + it('should return eligible components', () => { |
| 37 | + const components = {'amp-fit-text': '0.1', 'amp-layout': 'v0'}; |
| 38 | + const builders = getBuilders(components); |
| 39 | + expect(builders).have.all.keys(['amp-layout', 'amp-fit-text']); |
| 40 | + }); |
| 41 | +}); |
0 commit comments