mirror of
https://github.com/WowUp/WowUp.git
synced 2026-05-24 06:26:31 -04:00
Fixed download-count.pipe.spec.ts and a possible bug in addon.utils.ts
This commit is contained in:
@@ -10,7 +10,7 @@ import { TranslateMessageFormatCompiler } from "ngx-translate-messageformat-comp
|
||||
template: `<p>{{ number | downloadCount }}</p>`,
|
||||
})
|
||||
class TestDownloadCountComponent {
|
||||
public number: number = 1;
|
||||
public number: number = 0;
|
||||
}
|
||||
|
||||
describe("DownloadCountPipe", () => {
|
||||
|
||||
@@ -1,21 +1,50 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
|
||||
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
import { InterfaceFormatPipe } from "./interface-format.pipe";
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
@Component({
|
||||
template: `<p>{{ version | interfaceFormat }}</p>`,
|
||||
})
|
||||
class TestInterfaceFormatComponent {
|
||||
public version: string = "";
|
||||
}
|
||||
|
||||
describe("InterfaceFormatPipe", () => {
|
||||
let directive: InterfaceFormatPipe;
|
||||
let fixture: ComponentFixture<InterfaceFormatPipe>;
|
||||
let component: TestInterfaceFormatComponent;
|
||||
let fixture: ComponentFixture<TestInterfaceFormatComponent>;
|
||||
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [InterfaceFormatPipe],
|
||||
}).compileComponents();
|
||||
})
|
||||
);
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [TestInterfaceFormatComponent, InterfaceFormatPipe],
|
||||
}).compileComponents();
|
||||
|
||||
it("should create an instance", () => {
|
||||
fixture = TestBed.createComponent(InterfaceFormatPipe);
|
||||
directive = fixture.componentInstance;
|
||||
expect(directive).toBeTruthy();
|
||||
fixture = TestBed.createComponent(TestInterfaceFormatComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it("should create", () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should transform .toc format to semver", () => {
|
||||
component.version = "90002";
|
||||
fixture.detectChanges();
|
||||
let p = fixture.debugElement.nativeElement.querySelector("p");
|
||||
expect(p.innerHTML).toBe("9.0.2");
|
||||
});
|
||||
|
||||
it("should leave any dot version alone", () => {
|
||||
let p: HTMLElement;
|
||||
|
||||
component.version = "0.1";
|
||||
fixture.detectChanges();
|
||||
p = fixture.debugElement.nativeElement.querySelector("p");
|
||||
expect(p.innerHTML).toBe("0.1");
|
||||
|
||||
component.version = "8.3.1";
|
||||
fixture.detectChanges();
|
||||
p = fixture.debugElement.nativeElement.querySelector("p");
|
||||
expect(p.innerHTML).toBe("8.3.1");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ export function getGameVersion(gameVersion: string): string {
|
||||
return gameVersion;
|
||||
}
|
||||
|
||||
if (gameVersion.indexOf(".") !== -1) {
|
||||
if (gameVersion.toString().indexOf(".") !== -1) {
|
||||
return gameVersion;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user