123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- require('models/stack');
- describe('App.Stack', function () {
- var stack;
- beforeEach(function () {
- stack = App.Stack.createRecord();
- });
- describe('#stackNameVersion', function () {
- it('should concat stack name and stack version', function () {
- stack.setProperties({
- stackName: 'HDP',
- stackVersion: '2.5'
- });
- expect(stack.get('stackNameVersion')).to.equal('HDP-2.5');
- });
- });
- describe('#isPatch', function () {
- var cases = [
- {
- type: 'PATCH',
- isPatch: true
- },
- {
- type: 'STANDARD',
- isPatch: false
- }
- ];
- cases.forEach(function (item) {
- it(item.type, function () {
- stack.set('type', item.type);
- expect(stack.get('isPatch')).to.equal(item.isPatch);
- });
- });
- });
- describe('#displayName', function () {
- it('should concat stack name and stack version', function () {
- stack.setProperties({
- stackName: 'HDP',
- repositoryVersion: '2.5.0.0-999'
- });
- expect(stack.get('displayName')).to.equal('HDP-2.5.0.0-999');
- });
- });
- describe('#repositories', function () {
- beforeEach(function () {
- stack.reopen({
- operatingSystems: [
- Em.Object.create({
- isSelected: false,
- repositories: [
- {
- id: 0
- },
- {
- id: 1
- }
- ]
- }),
- Em.Object.create({
- isSelected: false,
- repositories: [
- {
- id: 2
- },
- {
- id: 3
- }
- ]
- }),
- Em.Object.create({
- isSelected: false,
- repositories: [
- {
- id: 4
- },
- {
- id: 5
- }
- ]
- })
- ]
- });
- });
- it('no OSes selected', function () {
- expect(stack.get('repositories')).to.be.empty;
- });
- it('some OSes selected', function () {
- stack.get('operatingSystems')[0].isSelected = true;
- stack.get('operatingSystems')[2].isSelected = true;
- expect(stack.get('repositories').toArray()).to.eql([
- {
- id: 0
- },
- {
- id: 1
- },
- {
- id: 4
- },
- {
- id: 5
- }
- ]);
- });
- });
- describe('#cleanReposBaseUrls', function () {
- beforeEach(function () {
- stack.reopen({
- operatingSystems: [
- Em.Object.create({
- isSelected: true,
- repositories: [
- Em.Object.create({
- baseUrl: 'http://localhost/repo0'
- }),
- Em.Object.create({
- baseUrl: 'http://localhost/repo1'
- })
- ]
- }),
- Em.Object.create({
- isSelected: true,
- repositories: [
- Em.Object.create({
- baseUrl: 'http://localhost/repo2'
- }),
- Em.Object.create({
- baseUrl: 'http://localhost/repo3'
- })
- ]
- })
- ]
- });
- stack.cleanReposBaseUrls();
- });
- it('should clear repo urls', function () {
- expect(stack.get('repositories').mapProperty('baseUrl')).to.eql(['', '', '', '']);
- });
- });
- describe('#restoreReposBaseUrls', function () {
- beforeEach(function () {
- stack.reopen({
- operatingSystems: [
- Em.Object.create({
- isSelected: true,
- repositories: [
- Em.Object.create({
- baseUrlInit: 'http://localhost/repo0'
- }),
- Em.Object.create({
- baseUrlInit: 'http://localhost/repo1'
- })
- ]
- }),
- Em.Object.create({
- isSelected: true,
- repositories: [
- Em.Object.create({
- baseUrlInit: 'http://localhost/repo2'
- }),
- Em.Object.create({
- baseUrlInit: 'http://localhost/repo3'
- })
- ]
- })
- ]
- });
- stack.restoreReposBaseUrls();
- });
- it('should reset repo urls', function () {
- expect(stack.get('repositories').mapProperty('baseUrl')).to.eql([
- 'http://localhost/repo0',
- 'http://localhost/repo1',
- 'http://localhost/repo2',
- 'http://localhost/repo3'
- ]);
- });
- });
- });
|