@@ -3,7 +3,7 @@ import { PreviewAppPluginsService } from "../../../lib/services/livesync/playgro
33import { Device } from "nativescript-preview-sdk" ;
44import { assert } from "chai" ;
55import * as util from "util" ;
6- import { PreviewAppMessages } from "../../../lib/services/livesync/playground/preview-app-constants" ;
6+ import { PluginComparisonMessages } from "../../../lib/services/livesync/playground/preview-app-constants" ;
77
88let readJsonParams : string [ ] = [ ] ;
99let warnParams : string [ ] = [ ] ;
@@ -32,7 +32,7 @@ function createTestInjector(localPlugins: IStringDictionary): IInjector {
3232const deviceId = "myTestDeviceId" ;
3333
3434function createDevice ( plugins : string ) : Device {
35- return {
35+ return {
3636 id : deviceId ,
3737 platform : "iOS" ,
3838 model : "myTestDeviceModel" ,
@@ -71,7 +71,7 @@ describe("previewAppPluginsService", () => {
7171 "tns-core-modules" : "~4.2.0"
7272 } ,
7373 expectedWarnings : [
74- util . format ( PreviewAppMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "nativescript-facebook" , deviceId )
74+ util . format ( PluginComparisonMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "nativescript-facebook" , deviceId )
7575 ]
7676 } ,
7777 {
@@ -84,34 +84,88 @@ describe("previewAppPluginsService", () => {
8484 previewAppPlugins : {
8585 } ,
8686 expectedWarnings : [
87- util . format ( PreviewAppMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "nativescript-facebook" , deviceId ) ,
88- util . format ( PreviewAppMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "nativescript-theme-core" , deviceId ) ,
89- util . format ( PreviewAppMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "tns-core-modules" , deviceId )
87+ util . format ( PluginComparisonMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "nativescript-facebook" , deviceId ) ,
88+ util . format ( PluginComparisonMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "nativescript-theme-core" , deviceId ) ,
89+ util . format ( PluginComparisonMessages . PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP , "tns-core-modules" , deviceId )
9090 ]
9191 } ,
9292 {
93- name : "should show warning for plugin which local version is greater than preview app's version" ,
93+ name : "should not show warnings when all plugins are included in preview app" ,
94+ localPlugins : {
95+ "nativescript-theme-core" : "1.0.4" ,
96+ "nativescript-facebook" : "2.2.3"
97+ } ,
98+ previewAppPlugins : {
99+ "nativescript-theme-core" : "1.1.4" ,
100+ "nativescript-facebook" : "2.2.3"
101+ } ,
102+ expectedWarnings : < string [ ] > [ ]
103+ } ,
104+ {
105+ name : "should show warning when local plugin has lower major version" ,
94106 localPlugins : {
95- "nativescript-theme-core" : "1.1.4 "
107+ "nativescript-theme-core" : "2.0.0 "
96108 } ,
97109 previewAppPlugins : {
98- "nativescript-theme-core" : "1.0.4 "
110+ "nativescript-theme-core" : "3.4.0 "
99111 } ,
100112 expectedWarnings : [
101- util . format ( PreviewAppMessages . PLUGIN_WITH_LOWER_VERSION_IN_PREVIEW_APP , "nativescript-theme-core" , "1.1.4 " , deviceId , "1.0.4 ")
113+ util . format ( PluginComparisonMessages . LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION , "nativescript-theme-core" , "2.0.0 " , "3.4.0 ")
102114 ]
103115 } ,
104116 {
105- name : "should not show warnings when all plugins are included in preview app " ,
117+ name : "should show warning when local plugin has greater major version " ,
106118 localPlugins : {
107- "nativescript-theme-core" : "1.0.4" ,
108- "nativescript-facebook" : "2.2.3"
119+ "nativescript-theme-core" : "4.0.0"
109120 } ,
110121 previewAppPlugins : {
111- "nativescript-theme-core" : "1.1.4" ,
112- "nativescript-facebook" : "2.2.3"
122+ "nativescript-theme-core" : "3.0.0"
113123 } ,
114- expectedWarnings : < string [ ] > [ ]
124+ expectedWarnings : [
125+ util . format ( PluginComparisonMessages . LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION , "nativescript-theme-core" , "4.0.0" , "3.0.0" )
126+ ]
127+ } ,
128+ {
129+ name : "should show warning when local plugin has greater minor version and the same major version" ,
130+ localPlugins : {
131+ "nativescript-theme-core" : "3.5.0"
132+ } ,
133+ previewAppPlugins : {
134+ "nativescript-theme-core" : "3.0.0"
135+ } ,
136+ expectedWarnings : [
137+ util . format ( PluginComparisonMessages . LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION , "nativescript-theme-core" , "3.5.0" , "3.0.0" )
138+ ]
139+ } ,
140+ {
141+ name : "should not show warning when local plugin has lower minor version and the same major version" ,
142+ localPlugins : {
143+ "nativescript-theme-core" : "3.1.0"
144+ } ,
145+ previewAppPlugins : {
146+ "nativescript-theme-core" : "3.2.0"
147+ } ,
148+ expectedWarnings : [ ]
149+ } ,
150+ {
151+ name : "should not show warning when plugins differ only in patch versions (lower local patch version)" ,
152+ localPlugins : {
153+ "nativescript-theme-core" : "3.5.0"
154+ } ,
155+ previewAppPlugins : {
156+ "nativescript-theme-core" : "3.5.1"
157+ } ,
158+ expectedWarnings : [ ]
159+ } ,
160+ {
161+ name : "should not show warning when plugins differ only in patch versions (greater local patch version)" ,
162+ localPlugins : {
163+ "nativescript-theme-core" : "3.5.1"
164+ } ,
165+ previewAppPlugins : {
166+ "nativescript-theme-core" : "3.5.0"
167+ } ,
168+ expectedWarnings : [ ]
115169 }
116170 ] ;
117171
0 commit comments