<commit_before>

fdescribe("Stargate share", function() {
    
    beforeEach(function() {
		hybrid_conf = null;
		country = null;
        isStargateOpen = false;
		isStargateInitialized = false;

		specTestMock = {
			onDeviceReady: function() {
				return onDeviceReady();
			}
		};

		cookie_mock._val.hybrid = 1;
		window.Cookies = cookie_mock;

		window.device = spec_device_mock;
		window.hostedwebapp = hostedwebapp_mock;
		window.cordova = cordova_mock;
		window.StatusBar = statusbar_mock;
		navigator.splashscreen = navigator_splashscreen_mock;
        navigator.connection = navigator_connection_mock;
		window.store = store_mock;
		window.storekit = storekit_mock;
		
		log = jasmine.createSpy();

		getManifest = function(){
			return Promise.resolve(manifest_mock);
		};

        document.removeEventListener("deviceready",onDeviceReady, false);
        
        if (!window.plugins) {
            window.plugins = {};
        }
        window.plugins.socialsharing = {
            shareWithOptions: function(options, onSuccess, onError) {
                //
            },
            shareViaFacebook: function(msg, img, url, onSuccess, onError) {
                //
            },
            shareViaTwitter: function(msg, img, url, onSuccess, onError) {
                //
            },
            shareViaWhatsApp: function(msg, img, url, onSuccess, onError) {
                //
            },
            canShareVia: function(via, message, subject, fileOrFileArray, url, onSuccess, onError) {
                //
            }
        };
    });
    
	it("isInitialized is false", function() {
		expect(stargatePublic.isInitialized()).toBeFalsy();
	});

	it("isOpen is false", function() {
		expect(stargatePublic.isOpen()).toBeFalsy();
	});

	it("socialShare require initialization", function(done) {
		var options = {};

		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/not initialized/);
		    done();
		});
        
	});

	it("socialShareAvailable require initialization", function() {
		var options = {};

		var res = stargatePublic.socialShareAvailable(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/not initialized/);
		    done();
		});
	});
    
    it("socialShare require opened stargate", function(done) {
		
        isStargateInitialized = true;
        
        var options = {};
        
		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/Stargate closed/);
		    done();
		});
        
	});

	it("socialShareAvailable require opened stargate", function() {
		
        isStargateInitialized = true;
        
        var options = {};

		var res = stargatePublic.socialShareAvailable(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/Stargate closed/);
		    done();
		});
	});

});<commit_msg>share full test<commit_after>

describe("Stargate share", function() {
    
    beforeEach(function() {
		hybrid_conf = null;
		country = null;
        isStargateOpen = false;
		isStargateInitialized = false;

		specTestMock = {
			onDeviceReady: function() {
				return onDeviceReady();
			}
		};

		cookie_mock._val.hybrid = 1;
		window.Cookies = cookie_mock;

		window.device = spec_device_mock;
		window.hostedwebapp = hostedwebapp_mock;
		window.cordova = cordova_mock;
		window.StatusBar = statusbar_mock;
		navigator.splashscreen = navigator_splashscreen_mock;
        navigator.connection = navigator_connection_mock;
		window.store = store_mock;
		window.storekit = storekit_mock;
		
		log = jasmine.createSpy();

		getManifest = function(){
			return Promise.resolve(manifest_mock);
		};

        document.removeEventListener("deviceready",onDeviceReady, false);
        
        if (!window.plugins) {
            window.plugins = {};
        }
        window.plugins.socialsharing = {
            shareWithOptions: function(options, onSuccess, onError) {
                onSuccess(true);
            },
            shareViaFacebook: function(msg, img, url, onSuccess, onError) {
                onSuccess(true);
            },
            shareViaTwitter: function(msg, img, url, onSuccess, onError) {
                onSuccess(true);
            },
            shareViaWhatsApp: function(msg, img, url, onSuccess, onError) {
                onSuccess(true);
            },
            canShareVia: function(via, message, subject, fileOrFileArray, url, onSuccess, onError) {
                //onError();
				onSuccess(true);
            }
        };
    });
    
	it("isInitialized is false", function() {
		expect(stargatePublic.isInitialized()).toBeFalsy();
	});

	it("isOpen is false", function() {
		expect(stargatePublic.isOpen()).toBeFalsy();
	});

	it("socialShare require initialization", function(done) {
		var options = {};

		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/not initialized/);
		    done();
		});
        
	});

	it("socialShareAvailable require initialization", function() {
		var options = {};

		var res = stargatePublic.socialShareAvailable(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/not initialized/);
		    done();
		});
	});
    
    it("socialShare require opened stargate", function(done) {
		
        isStargateInitialized = true;
        
        var options = {};
        
		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/Stargate closed/);
		    done();
		});
        
	});

	it("socialShareAvailable require opened stargate", function() {
		
        isStargateInitialized = true;
        
        var options = {};

		var res = stargatePublic.socialShareAvailable(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
            expect(message).toMatch(/Stargate closed/);
		    done();
		});
	});
	
	it("socialShare shareViaFacebook", function(done) {
		
        isStargateInitialized = true;
        isStargateOpen = true;
        
        var options = {
			"url": "http://www.google.com",
			"type": "facebook"
		};

		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
			console.log("stargatePublic.socialShare catch: "+message);
            expect(message).not.toBeDefined();
		    done();
		});
		
		res.then(function(result) {
			//console.log("stargatePublic.socialShare catch: "+result);
            expect(result).not.toBeFalsy();
		    done();
		});
	});
	
	it("socialShare shareWithTwitter", function(done) {
		
        isStargateInitialized = true;
        isStargateOpen = true;
        
        var options = {
			"url": "http://www.google.com",
			"type": "twitter"
		};

		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
			console.log("stargatePublic.socialShare catch: "+message);
            expect(message).not.toBeDefined();
		    done();
		});
		
		res.then(function(result) {
			//console.log("stargatePublic.socialShare catch: "+result);
            expect(result).not.toBeFalsy();
		    done();
		});
	});
	
	it("socialShare shareWithWhatsapp", function(done) {
		
        isStargateInitialized = true;
        isStargateOpen = true;
        
        var options = {
			"url": "http://www.google.com",
			"type": "whatsapp"
		};

		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
			console.log("stargatePublic.socialShare catch: "+message);
            expect(message).not.toBeDefined();
		    done();
		});
		
		res.then(function(result) {
			//console.log("stargatePublic.socialShare catch: "+result);
            expect(result).not.toBeFalsy();
		    done();
		});
	});
	
	it("socialShare shareWithChooser", function(done) {
		
        isStargateInitialized = true;
        isStargateOpen = true;
        
        var options = {
			"url": "http://www.google.com",
			"type": "chooser"
		};

		var res = stargatePublic.socialShare(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
			console.log("stargatePublic.socialShare catch: "+message);
            expect(message).not.toBeDefined();
		    done();
		});
		
		res.then(function(result) {
			//console.log("stargatePublic.socialShare catch: "+result);
            expect(result).not.toBeFalsy();
		    done();
		});
	});
	
	it("socialShare socialShareAvailable parameter error", function(done) {
		
        isStargateInitialized = true;
        isStargateOpen = true;
        
        var options = {
			"url": "http://www.google.com",
			"socials": "invalidparam"
		};

		var res = stargatePublic.socialShareAvailable(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
			//console.log("stargatePublic.socialShare catch: "+message);
            expect(message).toMatch(/missing array parameter socials/);
		    done();
		});
	});
	
	it("socialShare socialShareAvailable", function(done) {
		
        isStargateInitialized = true;
        isStargateOpen = true;
        
        var options = {
			"url": "http://www.google.com",
			"socials": ["facebook", "twitter", "instagram"]
		};

		var res = stargatePublic.socialShareAvailable(options);
        
        expect(res.then).toBeDefined();
        
		res.catch(function(message) {
			console.log("stargatePublic.socialShare catch: "+message);
            expect(message).not.toBeDefined();
		    done();
		});
		
		res.then(function(result) {
			//console.log("stargatePublic.socialShareAvailable result: "+result);
            expect(result).not.toBeFalsy();
            expect(result).toEqual(options.socials);
		    done();
		});
	});

});
{'fraction_non_alphanumeric': 0.13474355259345117, 'fraction_numerical': 0.00019318072056408772, 'mean_word_length': 2.396981627296588, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2200027', 'n_tokens_mistral': 3357, 'n_tokens_neox': 3050, 'n_words': 488}