Skip to content

Commit

Permalink
fix(gen): remedy test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Awk34 committed Oct 12, 2017
1 parent 689d0b2 commit f226df9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
13 changes: 13 additions & 0 deletions src/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,14 @@ export class Generator extends Base {
// Convert HTML into Pug
if(this.filters.pug) {
let pugFilter = filter(['**/*.html', '!client/_index.html'], {restore: true});

function pugReplacer(contents) {
return contents
.replace('ngif', 'ngIf')
.replace('ngfor', 'ngFor')
.replace('ngmodel', 'ngModel');
}

this.registerTransformStream([
pugFilter,
html2jade({
Expand All @@ -552,6 +560,11 @@ export class Generator extends Base {
rename(path => {
path.extname = '.pug';
}),
tap(function(file, t) {
var contents = file.contents.toString();
contents = pugReplacer(contents);
file.contents = new Buffer(contents);
}),
pugFilter.restore
]);
}
Expand Down
1 change: 1 addition & 0 deletions src/test/get-expected-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export function app(options) {
/* WebSockets */
if (options.ws) {
files = files.concat([
'client/components/socket/primus.mock.' + script,
'client/components/socket/socket.service.' + script,
'client/components/socket/socket.mock.' + script,
'server/api/thing/thing.socket.js',
Expand Down
2 changes: 1 addition & 1 deletion src/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('angular-fullstack:app', function() {
}
});

describe('with sequelize models, auth', function() {
describe.only('with sequelize models, auth', function() {
var dir;
var lintResult;
var clientTestResult;
Expand Down
11 changes: 6 additions & 5 deletions templates/app/client/app/main/main.component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ResponseOptions,
} from '@angular/http';
import { MockBackend } from '@angular/http/testing';
<%_ if(filters.expect) { -%>
<%_ if(filters.mocha && filters.expect) { -%>
import { expect } from 'chai';<% } %><% if(filters.uibootstrap) { %>
import { TooltipModule } from 'ngx-bootstrap';<% } %>
import { FormsModule } from '@angular/forms';
Expand Down Expand Up @@ -49,15 +49,15 @@ describe('Component: MainComponent', function() {
}).compileComponents();
}));
<%_ if(filters.ws) { %>
beforeEach('mock backend', async(inject([MockBackend], (mockBackend) => {
beforeEach(async(inject([MockBackend], (mockBackend) => {
mockBackend.connections.subscribe(conn => {
conn.mockRespond(new Response(new ResponseOptions({
body: JSON.stringify(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express'])
})));
});
})));<% } %>

beforeEach('ngOnInit', async(() => {
beforeEach(async(() => {
fixture = TestBed.createComponent(MainComponent);
// MainComponent test instance
comp = fixture.componentInstance;
Expand All @@ -68,7 +68,8 @@ describe('Component: MainComponent', function() {
fixture.detectChanges();
}));

it('should attach a list of things to the controller', () => {
expect(comp.awesomeThings.length).to.equal(4);
it('should attach a list of things to the controller', () => {<% if(filters.jasmine) { %>
expect(comp.awesomeThings.length).toEqual(4);<% } else if(filters.mocha) { -%>
<%= expect() %>comp.awesomeThings.length<%= to() %>.equal(4);<% } %>
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
<%_ if(filters.expect) { -%>
<%_ if(filters.mocha && filters.expect) { -%>
import { expect } from 'chai';<% } %>

import { OauthButtonsComponent } from './oauth-buttons.component';
Expand Down
2 changes: 1 addition & 1 deletion templates/app/client/components/util.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { safeCb } from './util';
<%_ if(filters.expect) { -%>
<%_ if(filters.mocha && filters.expect) { -%>
import { expect } from 'chai';<% } %>

describe('Util', () => {
Expand Down
4 changes: 2 additions & 2 deletions templates/app/tsconfig(ts).json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseDir": ".",
"baseUrl": ".",
"experimentalDecorators": true,
"sourceMap": true,
"rootDir": "./",
"module": "es6",
"outDir": ".tmp",<% if(filters.ws) %>
"outDir": ".tmp",<% if(filters.ws) { %>
"paths": {
"primus": ["client/components/socket/primus.js"]
},<% } %>
Expand Down

0 comments on commit f226df9

Please sign in to comment.